<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.dir(Promise);
        function ajax() {
            return new Promise(function (resolve, reject) {
                setTimeout(function () {
                    resolve("haogu")
                    //reject("error")
                })
            })
        }
        ajax().then((data) => { //resolve 成功的时候走的这里
            console.log(data);
        }).catch(function (err) {  //reject执行的是catch
            console.log(err);
        }).finally(function () { //成功或者失败都执行
            console.log("请求完成");
        })
    </script>
</body>

</html>